package com.luo.controller;

import com.luo.pojo.Department;
import com.luo.service.DepartmentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/department")
public class DepartmentController {

    @Resource
    private DepartmentService departmentService;

    @RequestMapping(value = "/selectDepartmentList",method = RequestMethod.GET)
    public Map<String,Object> selectDepartmentList(@RequestParam int page,
                                                   @RequestParam int limit,
                                                   String departmentName,
                                                   String departmentCode){
       return departmentService.selectDepartmentList(departmentName,departmentCode,page,limit);

    }

    @RequestMapping(value = "selectDepartmentNames",method = {RequestMethod.GET,RequestMethod.POST})
    public Map<String,Object>selectDepartmentNames(){
        return departmentService.selectDepartmentNames();
    }

    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public Map<String,Object> inset(@RequestBody Department department){
        return departmentService.insert(department);
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public Map<String,Object> update(@RequestBody Department department){
        return departmentService.update(department);
    }

    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    public Map<String,Object> delete(Integer id){
        return departmentService.delete(id);
    }


}
